import gitTag from './gitTag.vue'
import jiraTag from './jiraTag.vue'
export const crudOptions = (vm) => {
  return {
    pageOptions: {
      compact: true
    },
    options: {
      // tableType: 'vxe-table',
      // rowKey: true, // 必须设置，true or false
      rowId: 'id',
      height: '100%', // 表格高度100%, 使用toolbar必须设置
      highlightCurrentRow: false,
      defaultExpandAll: true
      // treeConfig: { // 树形数据配置
      //   expandAll: true,
      //   children: 'children',
      // }
    },
    rowHandle: {
      width: 140,
      view: {
        thin: true,
        text: '',
        disabled () {
          return !vm.hasPermissions('Retrieve')
        }
      },
      edit: {
        thin: true,
        text: '',
        disabled () {
          return !vm.hasPermissions('Update')
        }
      },
      remove: {
        thin: true,
        text: '',
        disabled () {
          return !vm.hasPermissions('Delete')
        }
      }
    },
    indexRow: { // 或者直接传true,不显示title，不居中
      title: '序号',
      align: 'center',
      width: 100
    },

    viewOptions: {
      componentType: 'form'
    },
    formOptions: {
      defaultSpan: 12 // 默认的表单 span
    },
    columns: [{
      title: '关键词',
      key: 'search',
      show: false,
      disabled: true,
      search: {
        disabled: false
      },
      form: {
        disabled: true,
        component: {
          props: {
            clearable: true
          },
          placeholder: '请输入关键词'
        }
      },
      view: { // 查看对话框组件的单独配置
        disabled: true
      }
    },
    {
      title: 'ID',
      key: 'id',
      show: false,
      disabled: true,
      width: 90,
      form: {
        disabled: true
      }
    },
    {
      title: '工单编号',
      key: 'jira_id',
      show: true,
      disabled: false,
      search: {
        disabled: false,
        component: {
          props: {
            clearable: true
          }
        }
      },
      width: 180,
      type: 'input',
      component: {
        name: jiraTag
      },
      form: {
        rules: [ // 表单校验规则
          { required: true, message: '工单编号必填项' }
        ],
        component: {
          span: 12,
          props: {
            clearable: true
          },
          placeholder: '请输入工单编号'
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: '提交编号',
      key: 'commit_id',
      search: {
        disabled: false,
        component: {
          props: {
            clearable: true
          }
        }
      },
      width: 180,
      type: 'input',
      form: {
        rules: [ // 表单校验规则
          { required: true, message: '提交编号必填项' }
        ],
        component: {
          span: 12,
          props: {
            clearable: true
          },
          placeholder: '请输入提交编号'
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: '详情',
      key: 'summary',
      width: 180,
      type: 'input',
      form: {
        rules: [ // 表单校验规则
          { required: true, message: '详情必填项' }
        ],
        component: {
          span: 12,
          props: {
            clearable: true
          },
          placeholder: '请输入详情信息'
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: '责任人',
      key: 'owner',
      form: {
        component: {
          span: 12,
          props: {
            clearable: true
          },
          placeholder: '请输入责任人'
        }
      }
    },
    {
      title: '代码详情',
      key: 'git_ci',
      component: {
        name: gitTag
      },
      form: {
        component: {
          span: 12,
          props: {
            clearable: true
          },
          placeholder: '请输入代码详情'
        }
      }
    },
    {
      title: '测试人员',
      key: 'tester',
      form: {
        component: {
          span: 12,
          props: {
            clearable: true
          },
          placeholder: '请输入测试人员名称'
        }
      }
    }, {
      title: '项目',
      key: 'project',
      width: 80,
      type: 'input',
      search: {
        disabled: false,
        component: {
          props: {
            clearable: true
          }
        }
      },
      form: {
        component: {
          span: 12,
          placeholder: '请输入项目名称'
        }
      }
    },
    {
      title: '状态',
      key: 'status',
      width: 80,
      type: 'input',
      form: {
        component: {
          span: 12,
          placeholder: '请输入状态'
        }
      }
    },
    {
      title: '错误详情',
      key: 'error_msg',
      width: 80,
      type: 'input',
      form: {
        component: {
          span: 12,
          placeholder: '请输入错误详情'
        }
      }
    }
    ].concat(vm.commonEndColumns())
  }
}
